const Koa = require('koa');
const bodyParser = require('koa-bodyparser');
const app = new Koa();
//处理路由
const useRoutes = require('../router');
//解决跨域问题
app.use(async (ctx, next) => {
  ctx.set('Access-Control-Allow-Origin', '*');
  ctx.set('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild');
  ctx.set('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
  await next();
});
//处理post请求
app.use(bodyParser());
//处理路由
useRoutes(app)
module.exports = app;